package net.zdreamer.shunyi.utils;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Point;
import android.view.WindowManager;

public class WindowUtil {
	/**
	 * 获取屏幕的宽和高  Api 13以上
	 * @param context 上下文
	 * @return Point对象  Pint.x 为 宽   Pint.y = 高
	 */
	@SuppressLint("NewApi")
	public static Point getWindowSize(Context context){
		WindowManager manager = (WindowManager)
		context.getSystemService(Context.WINDOW_SERVICE);
		Point outSize = new Point();
		manager.getDefaultDisplay().getSize(outSize);
		return outSize;
	}
	/**
	 * 获取屏幕宽和高 Api 8以上
	 * @param context 上下文
	 * @return int[]  int[0] 为宽  int[1] 高
	 */
	public static int[] getWindow(Context context){
		WindowManager manager = (WindowManager)
				context.getSystemService(Context.WINDOW_SERVICE);
		int[] size = new int[2];
		size[0] = manager.getDefaultDisplay().getWidth();
		size[1] = manager.getDefaultDisplay().getHeight();
		return size;
	}
}